﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Plusii.iiWeb;
using R.DMS.Data;

namespace R.DMS.UI.Framework
{
    /// <summary>
    /// 欢迎
    /// </summary>
    public partial class Welcome : iiPage
    {
        CommonBusiness service = new CommonBusiness();

        /// <summary>
        /// 页面加载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                #region 验证权限

                #endregion

                #region 获取参数

                #endregion

                //初始化
                this.Initialize();
            }

            #region 页面标题

            this.Title = this.PageID;

            #endregion

            #region 页面要素

            #endregion
        }

        #region 初始化

        private void Initialize()
        {
            #region 页面内容

            #endregion

            this.BindList();
        }

        #endregion

        #region 绑定数据

        private void BindList()
        {
            var list = service.GetFileList(string.Empty, string.Empty, EnumUploadFileType.Policy.GetHashCode().ToString())
                              .OrderByDescending(a => a.F_CreateTime)
                              .ToList();
            list.ForEach(f =>
            {
                string format = LocalGlobal.LinkFormat;
                f.F_Link = string.Format(format, f.F_FilePath, f.F_CreatorUserId, f.F_CreateTime.ToString(LocalGlobal.DateFormat), f.F_FileName.Trim());
            });

            List.DataSource = list;
            List.DataBind();
        }

        protected void List_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            switch (e.Row.RowType)
            {
                //数据行
                case DataControlRowType.DataRow:
                    #region 数据绑定

                    #endregion
                    break;

                case DataControlRowType.EmptyDataRow:
                case DataControlRowType.Header:
                case DataControlRowType.Separator:
                case DataControlRowType.Pager:
                case DataControlRowType.Footer:
                default:
                    break;
            }
        }

        /// <summary>
        /// 翻页
        /// </summary>
        protected void List_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            List.PageIndex = e.NewPageIndex;
            this.BindList();
        }

        #endregion
    }
}